package de.fmannan.addbook;

import org.apache.log4j.Logger;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.widgets.Display;


public class MyImageRegistry {

	private static final Logger log = Logger.getLogger(MyImageRegistry.class);
	private static ImageRegistry registry = null;
	
	public static final String SAVE_ICON = "save";
	public static final String REMOVE_ICON = "remove";
	public static final String FIND_ICON = "find";
	public static final String VIEW_ICON = "view";
	public static final String CONTACT_ICON = "contact";
	public static final String GROUP_ICON = "group";
	public static final String EDIT_ICON = "edit";
	public static final String BOOK_YELLOW_ICON = "book_yellow";
	public static final String BOOK_BLUE_ICON = "book_blue";
	public static final String ABOUT_ICON = "about";
	public static final String PDA_WRITE_ICON = "pda_write";
	public static final String MODEM_EARTH_ICON = "modem_earth";
	public static final String MDA_ICON = "mda";
	public static final String ANGEL_ICON = "angel";
	public static final String DEVIL_ICON = "devil";
	public static final String HOME_ICON = "home";
	public static final String OFFICE_ICON = "office";
	
	
	/**
	 * Adds images to an {@link ImageRegistry}, so that they can be reused
	 * within the code. This might be the case when you have to create a
	 * popup-menu with code rather than extension points and you want to use
	 * custom images.
	 */
	public static void loadImages(Display display) {
		log.debug("Loading image registry");
		// Creating new instance of the ImageRegistry
		registry = new ImageRegistry(display);
		
		registry.put(BOOK_YELLOW_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/book_yellow.png"));
		registry.put(REMOVE_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/remove.png"));
		registry.put(FIND_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/find.png"));		
		registry.put(VIEW_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/view.png"));
		registry.put(CONTACT_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/contact.png"));
		registry.put(GROUP_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/group.png"));		
		registry.put(BOOK_BLUE_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/book_blue.png"));			
		registry.put(SAVE_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/save.png"));			
		registry.put(EDIT_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/edit.png"));			
		registry.put(ABOUT_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/about.png"));			
		registry.put(PDA_WRITE_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/pda_write.png"));		
		registry.put(MODEM_EARTH_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/modem_earth.png"));			
		registry.put(MDA_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/mda.png"));			
		registry.put(ANGEL_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/angel.png"));			
		registry.put(DEVIL_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/devil.png"));			
		registry.put(HOME_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/house.png"));			
		registry.put(OFFICE_ICON, ImageDescriptor.createFromFile(
				MyImageRegistry.class, "/ressource/office_building.png"));			
	}
	
	public static ImageRegistry getImageRegistry () {
		return registry;
	}
}
